package com.asm.controller.api;

import com.asm.controller.BaseController;
import com.asm.dto.PageResult;
import com.asm.dto.Result;
import com.asm.service.SpotScheduleService;
import com.asm.vo.sys.SpotScheduleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author CrysTzj
 * @author ZhuangGuiMan
 * @program AdvertisementManagementSystem
 * @description 广告位档期接口逻辑设计
 * @date  2019-07-11 00:07
 **/
@Api(value = "广告位档期Controller")
@Slf4j
@RestController
public class SpotScheduleController extends BaseController {
    @Resource
    private SpotScheduleService spotScheduleService;

    /**
     * 根据广告位编号查询广告位档期
     *
     * @param id 广告位编号
     * @return 广告位档期
     */
    @ApiOperation(value = "根据广告位编号查询广告位档期", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "广告位编号"),
            @ApiImplicitParam(name = "pageNumber", value = "当前页码"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小")
    })
    @GetMapping("/spotSchedule/{id}")
    public ResponseEntity<PageResult<SpotScheduleVo>> getSpotScheduleBySpotId(@PathVariable("id") Long id, @RequestParam(value = "pageNumber", defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", spotScheduleService.getSpotScheduleBySpotId(id, pageNumber, pageSize)), HttpStatus.OK);
    }
}
